import Mock from 'mockjs';
const count = 100;

const tableList = [
    {
        uuid: '000124', // 必须项
        skuNo: 'SKU0000001',
        shopName: 'store0000000149',
        productName: 'Apple iPhone 11 Pro (A2217)',
        productNo: 12121,
        brand: '苹果',
        category: '全部商品分类>手机/运营商/数码>手机通讯>手机',
        productStatus: '0',
        auditStatus: '0',
        'actions': [
            {
                name: 'View',
                label: '查看',
                handleType: 'link'
            },
            {
                name: 'Edit',
                label: '编辑',
                handleType: 'link'
            },
            {
                name: 'Delete',
                label: '删除'
            }
        ]
    },
    {
        uuid: '000124', // 必须项
        skuNo: 'SKU0000002',
        shopName: 'qwcs新商',
        productName: '朝香 清酒 纯米酒 1800ml ',
        productNo: 1087005,
        brand: '朝香',
        category: '',
        productStatus: '0',
        auditStatus: '0'
    },
    {
        uuid: '000124', // 必须项
        skuNo: 'SKU0000003',
        shopName: 'qwcs新商',
        productName:
            '飞利浦 (PHILIPS) 蒸汽挂烫机 家用手持/挂式电熨斗双杆带烫衣板 2200W三档调节熨衣GC625/28（GC617升级款）',
        productNo: 100007907060,
        brand: '飞利浦（PHILIPS）',
        category: '全部商品分类>家用电器>生活电器>挂烫机/熨斗',
        productStatus: '1',
        auditStatus: '1'
    },
    {
        uuid: '000124', // 必须项
        skuNo: 'SKU0000004',
        shopName: 'qwcs新商',
        productName:
            '卫仕配方羊奶粉400g 宠物羊奶粉 狗狗奶粉 幼犬猫奶粉 泰迪金毛亲母乳配方犬猫通用奶粉（新老包装交替发货）',
        productNo: 4907717,
        brand: '卫仕（NOURSE）',
        category: ' ',
        productStatus: '0',
        auditStatus: '0'
    },
    {
        uuid: '000124', // 必须项
        skuNo: 'SKU0000005',
        shopName: 'qwcs新商',
        productName:
            '威刚（ADATA）DDR4 3600 16GB (8G×2)套装 台式机内存 XPG-Z1 游戏威龙(金色)',
        productNo: 6959207,
        brand: '威刚（ADATA）',
        category: '',
        productStatus: '0',
        auditStatus: '0'
    },
    {
        uuid: '000124', // 必须项
        skuNo: 'SKU0000006',
        shopName: 'qwcs新商',
        productName:
            '布舍元 女靴女士高帮加绒保暖中老年人橡胶底防滑套脚休闲妈妈棉鞋 94y-0728 红色 ',
        productNo: 35100004505763,
        brand: '布舍元（BUSHEYUAN）',
        category:
            '全部商品分类>女鞋/箱包/钟表/珠宝>时尚女鞋>雪地靴',
        productStatus: '1',
        auditStatus: '1'
    },
    {
        uuid: '000124', // 必须项
        skuNo: 'SKU0000007',
        shopName: 'qwcs新商',
        productName: '朝香 清酒 纯米酒 1800ml ',
        productNo: 1087005,
        brand: '朝香',
        category: '',
        productStatus: '0',
        auditStatus: '0'
    },
    {
        uuid: '000124', // 必须项
        skuNo: 'SKU0000008',
        shopName: 'qwcs新商',
        productName:
            '飞利浦 (PHILIPS) 蒸汽挂烫机 家用手持/挂式电熨斗双杆带烫衣板 2200W三档调节熨衣GC625/28（GC617升级款）',
        productNo: 100007907060,
        brand: '飞利浦（PHILIPS）',
        category: '全部商品分类>家用电器>生活电器>挂烫机/熨斗',
        productStatus: '1',
        auditStatus: '1'
    },
    {
        uuid: '000124', // 必须项
        skuNo: 'SKU0000009',
        shopName: 'qwcs新商',
        productName:
            '卫仕配方羊奶粉400g 宠物羊奶粉 狗狗奶粉 幼犬猫奶粉 泰迪金毛亲母乳配方犬猫通用奶粉（新老包装交替发货）',
        productNo: 4907717,
        brand: '卫仕（NOURSE）',
        category: ' ',
        productStatus: '0',
        auditStatus: '0'
    },
    {
        uuid: '000124', // 必须项
        skuNo: 'SKU0000010',
        shopName: 'qwcs新商',
        productName:
            '威刚（ADATA）DDR4 3600 16GB (8G×2)套装 台式机内存 XPG-Z1 游戏威龙(金色)',
        productNo: 6959207,
        brand: '威刚（ADATA）',
        category: '',
        productStatus: '0',
        auditStatus: '0'
    },
    {
        uuid: '000124', // 必须项
        skuNo: 'SKU0000011',
        shopName: 'qwcs新商',
        productName:
            '布舍元 女靴女士高帮加绒保暖中老年人橡胶底防滑套脚休闲妈妈棉鞋 94y-0728 红色 ',
        productNo: 35100004505763,
        brand: '布舍元（BUSHEYUAN）',
        category:
            '全部商品分类>女鞋/箱包/钟表/珠宝>时尚女鞋>雪地靴',
        productStatus: '1',
        auditStatus: '1'
    },
    {
        uuid: '000124', // 必须项
        skuNo: 'SKU0000012',
        shopName: 'qwcs新商',
        productName: '派格（paiger）办公家具 床1.2米 TYNH',
        productNo: 100006784640,
        brand: '派格',
        category: '',
        productStatus: '1',
        auditStatus: '1  '
    },
    {
        uuid: '000124', // 必须项
        skuNo: 'SKU0000013',
        shopName: 'qwcs新商',
        productName:
            '积优JEAYOU 真皮表带男 适用于天梭力洛克美度浪琴DW欧米茄手表配件表链22AZP10',
        productNo: 3247165,
        brand: '积优（JEAYOU）',
        category:
            '全部商品分类>女鞋/箱包/钟表/珠宝>钟表>钟表配件',
        productStatus: '0',
        auditStatus: '1'
    },
    {
        uuid: '000124', // 必须项
        skuNo: 'SKU0000014',
        shopName: 'qwcs新商',
        productName:
            '三星32GB TF（MicroSD） 传输速度95MB/s U1 C10 EVO升级版存储卡 行车记录仪适配',
        productNo: 100003415476,
        brand: '三星（SAMSUNG）',
        category:
            '全部商品分类>房产/汽车/汽车用品>汽车装饰>车载电器配件',
        productStatus: '1',
        auditStatus: '0'
    },
    {
        skuNo: 'SKU0000015',
        shopName: 'qwcs新商',
        productName:
            '库阿森 KINGSIR 电动车护膝摩托车骑车防风护腿男女士冬季骑行护具保暖加厚防寒长',
        productNo: 100008488894,
        brand: '库阿森（KINGSIR）',
        category: '',
        productStatus: '0',
        auditStatus: '0'
    },
    {
        skuNo: 'SKU0000016',
        shopName: 'qwcs新商',
        productName: '派格（paiger）办公家具 床1.2米 TYNH',
        productNo: 100006784640,
        brand: '派格',
        category: '',
        productStatus: '1',
        auditStatus: '1  '
    },
    {
        skuNo: 'SKU0000017',
        shopName: 'qwcs新商',
        productName:
            '积优JEAYOU 真皮表带男 适用于天梭力洛克美度浪琴DW欧米茄手表配件表链22AZP10',
        productNo: 3247165,
        brand: '积优（JEAYOU）',
        category:
            '全部商品分类>女鞋/箱包/钟表/珠宝>钟表>钟表配件',
        productStatus: '0',
        auditStatus: '1'
    },
    {
        skuNo: 'SKU0000018',
        shopName: 'qwcs新商',
        productName:
            '三星32GB TF（MicroSD） 传输速度95MB/s U1 C10 EVO升级版存储卡 行车记录仪适配',
        productNo: 100003415476,
        brand: '三星（SAMSUNG）',
        category:
            '全部商品分类>房产/汽车/汽车用品>汽车装饰>车载电器配件',
        productStatus: '1',
        auditStatus: '0'
    },
    {
        skuNo: 'SKU0000019',
        shopName: 'qwcs新商',
        productName:
            '库阿森 KINGSIR 电动车护膝摩托车骑车防风护腿男女士冬季骑行护具保暖加厚防寒长',
        productNo: 100008488894,
        brand: '库阿森（KINGSIR）',
        category: '',
        productStatus: '0',
        auditStatus: '0'
    }
];

let memberTableList = [];
for (let i = 0; i < count; i++) {
    memberTableList.push(Mock.mock({
        'uuid': '@increment()', // 必须项
        memberId: 'm0000001',
        kehu: '@cname',
        address: '@province @city @county',
        'qycard|1': ['88Vip', '66Vip', '99Vip'],
        'point|+1': 12121,
        czmoney: '@increment(1)',
        buyNum: 345,
        xfMoney: 1383,
        releaseTime: '@date(yyyy-MM-dd)', // data选择范围是 是数组形式 如：['2019-12-13,2019-12-13]
        'brandLogo|1': [ // 默认列表 同iview组件的 defaultList
            [{
                name: '小头1', // 图片name
                url: 'https://dev-file.iviewui.com/BbnuuEiM0QXNPHVCvb3E2AFrawIjCkqW/avatar' // 图片url
            }],
            [{
                name: '小头像', // 图片name
                url: 'https://dev-file.iviewui.com/userinforaP8NeQgYpmKgkpWlqZP7rfewbHiIzJY/avatar' // 图片url
            }]
        ],
        'area|1': [
            ['beijing', 'tiantan']
        ],
        'isRelease|1': ['0', '1'],
        'relationShops|1': [
            ['0', '1'],
            ['0', '2'],
            ['0', '3'],
            ['1', '2'],
            ['1', '3'],
            ['2', '3']
        ],
        'descInfo|10-20': '@cname',
        'actions|1': [
            [
                {
                    name: 'View',
                    label: '查看',
                    handleType: 'link'
                },
                {
                    name: 'Edit',
                    label: '编辑',
                    handleType: 'link'
                },
                {
                    name: 'Audit',
                    label: '审核',
                    handleType: 'link'
                },
                {
                    name: 'Delete',
                    label: '删除'
                }
            ],
            [
                {
                    name: 'Audit',
                    label: '审核',
                    handleType: 'link'
                },
                {
                    name: 'Delete',
                    label: '删除'
                }
            ], [
                {
                    name: 'View',
                    label: '查看',
                    handleType: 'link'
                },
                {
                    name: 'Edit',
                    label: '编辑',
                    handleType: 'link'
                },
                {
                    name: 'Delete',
                    label: '删除'
                }
            ]
        ]
    }))
}

export default [
    {
        path: '/api/getTableList',
        method: 'get',
        handle ({ body }) {
            const start = body.pageInfo.nowPage * body.pageInfo.pageShow - body.pageInfo.pageShow;
            const end = start + body.pageInfo.pageShow;

            let data = {
                list: [...tableList].slice(start, end),
                pageInfo: {
                    nowPage: 1, // 当前页数
                    pageShow: body.pageInfo.pageShow, // 每页显示条数
                    totalPage: count / body.pageInfo.pageShow, // 总页数
                    totalNum: count // 总条数
                }
            }
            if (body.pageInfo.nowPage) {
                return {
                    code: 0,
                    msg: '获取数据成功',
                    data: data
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    },
    {
        path: '/api/getMemberList',
        method: 'get',
        handle ({ body }) {
            const start = body.pageInfo.nowPage * body.pageInfo.pageShow - body.pageInfo.pageShow;
            const end = start + body.pageInfo.pageShow;
            let data = {
                return_code: 0,
                list: [...memberTableList].slice(start, end),
                pageInfo: {
                    nowPage: 1, // 当前页数
                    pageShow: body.pageInfo.pageShow, // 每页显示条数
                    totalPage: count / body.pageInfo.pageShow, // 总页数
                    totalNum: count // 总条数
                }
            }
            if (body.pageInfo.nowPage) {
                return {
                    code: 0,
                    msg: '获取数据成功',
                    data: data
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    },
    {
        path: '/api/editMemberInfo',
        method: 'get',
        handle ({ body }) {
            if (body.uuid) {
                for (let i = 0; i < memberTableList.length; i++) {
                    if (Number(body.uuid) === memberTableList[i].uuid) {
                        memberTableList[i] = body;
                        break;
                    }
                }
                return {
                    code: 0,
                    msg: '编辑数据成功',
                    data: {
                        return_code: 0
                    }
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    },
    {
        path: '/api/auditMemberInfo',
        method: 'get',
        handle ({ body }) {
            if (body.memberId) {
                return {
                    code: 0,
                    msg: '审核数据成功',
                    data: {
                        return_code: 0
                    }
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    },
    {
        path: '/api/delMemberInfo',
        method: 'get',
        handle ({ body }) {
            if (body.uuid) {
                return {
                    code: 0,
                    msg: '删除数据成功',
                    data: {
                        return_code: 0
                    }
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    },
    {

        path: '/api/addMemberInfo',
        method: 'get',
        handle ({ body }) {
            if (body.userName) {
                memberTableList.unshift(body.formData);
                return {
                    code: 0,
                    msg: '',
                    data: {
                        return_code: 0
                    }
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    },
    {

        path: '/api/getViewPageInfo',
        method: 'get',
        handle ({ body }) {
            if (body.uuid) {
                let memberInfo = {};
                for (let i = 0; i < memberTableList.length; i++) {
                    if (Number(body.uuid) === memberTableList[i].uuid) {
                        memberInfo = memberTableList[i];
                        break;
                    }
                }

                return {
                    code: 0,
                    msg: '',
                    data: {
                        data: memberInfo,
                        return_code: 0
                    }
                }
            } else {
                return {
                    code: 401,
                    msg: '接口请求超时',
                    data: {}
                }
            }
        }
    }
]
